#ifndef controler_compil_h
#define controler_compil_h

#include <vector>
#include <utility>
#include <string>
#include "IdentTable.hpp"
#include "SymbolType.hpp"
#include "SymbolTablesManager.hpp"
#include "ExpressionsManager.hpp"
#include "CodeContainer.hpp"


class Controler;
extern int yyerror(Controler * controler,  char const *msg);

class Controler {
	private:
		int inTypeDef;
		IdentTable * identTable;
		SymbolTablesManager * symbolTablesManager;
		ExpressionsManager * expressionsManager;
		CodeContainer * outputCode;

	public:
		Controler() {
			inTypeDef=0;

			identTable = new IdentTable;
			symbolTablesManager = new SymbolTablesManager;
			expressionsManager = new ExpressionsManager(identTable, symbolTablesManager);
			outputCode = new CodeContainer;
		}

		~Controler() {
			delete identTable;
			delete symbolTablesManager;
			delete expressionsManager;
			delete outputCode;
		}

		IdentTable * getIdentTable (){
			return this->identTable;
		}

		SymbolTablesManager * getSymbolTablesManager() {
			return this->symbolTablesManager;
		}

		ExpressionsManager * getExpressionsManager() {
			return this->expressionsManager;
		}

		void errorMsg(const std::string & msg){
			yyerror(this, msg.c_str());
		}
		void enterTypeDef(){
			this->inTypeDef ++;
		}
		void quitTypeDef(){
			this->inTypeDef --;
		}
		bool isInTypeDef(){
			return this->inTypeDef>0;
		}



		void addToOutputCode(CodeContainer * code) {
			outputCode->add(code);
		}

		void showOutputCode() {
			outputCode->show(identTable);
		}
};

#endif
